"""AppImage rules for Bazel."""

module(name = "rules_appimage", version = "1.8.0")

bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_python", version = "0.29.0")
bazel_dep(name = "squashfs-tools", version = "4.6.1")
bazel_dep(name = "zstd", version = "1.5.5.bcr.1")

rules_appimage = use_extension("//:extensions.bzl", "appimage_ext_dependencies")
use_repo(
    rules_appimage,
    "appimage_runtime_aarch64",
    "appimage_runtime_i386",
    "appimage_runtime_armv7e-m",
    "appimage_runtime_x86_64",
    "appimagetool.png",
)

register_toolchains("//appimage:all")

PYTHON_VERSIONS = [
    "3.8",
    "3.9",
    "3.10",
    "3.11",
    "3.12",
]

python = use_extension("@rules_python//python/extensions:python.bzl", "python")

[
    python.toolchain(
        is_default = python_version == PYTHON_VERSIONS[-1],
        python_version = python_version,
    )
    for python_version in PYTHON_VERSIONS
]

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")

[
    pip.parse(
        hub_name = "rules_appimage_py_deps",
        python_version = python_version,
        requirements_lock = "//:requirements.txt",
    )
    for python_version in PYTHON_VERSIONS
]

use_repo(pip, "rules_appimage_py_deps")
